package com.ctshk.sapp.system.controller;


import com.ctshk.common.annotations.OperationLogAnnotation;
import com.ctshk.common.dto.Result;
import com.ctshk.common.enums.OperationLogModel;
import com.ctshk.common.enums.OperationLogType;
import com.ctshk.common.model.PageResponse;
import com.ctshk.common.model.TokenUser;
import com.ctshk.rpc.system.dto.MainDataTourGroupCodeQueryDTO;
import com.ctshk.rpc.system.dto.MainDataTourGroupDTO;
import com.ctshk.rpc.system.dto.MainDataTourGroupListDTO;
import com.ctshk.rpc.system.dto.MainDataTourGroupQueryDTO;
import com.ctshk.rpc.system.req.*;
import com.ctshk.rpc.system.service.IMainDataTourGroupService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;
import com.ctshk.common.web.support.BaseController;

import javax.validation.Valid;
import java.util.List;

/**
 * <p>
 * 旅游组别表 前端控制器
 * </p>
 *
 * @author 谢诗宏
 * @since 2021-01-30
 */
@Api(value = "主数据旅游组别",tags = "主数据旅游组别")
@RestController
@RequestMapping("/main/data/tour/group")
public class MainDataTourGroupController extends BaseController {


    @DubboReference
    private IMainDataTourGroupService iMainDataTourGroupService;

    /**
     * 新增旅游组别
     */
    @ApiOperation(value = "新增旅游组别", notes = "新增旅游组别")
    @OperationLogAnnotation(operModul = OperationLogModel.SYSTEM, operType = OperationLogType.ADD, operTitle = "新增旅游组别", operDesc = "新增旅游组别")
    @PostMapping("/add")
    public Result add(@RequestBody @Valid MainDataTourGroupAddReq req) {
        return iMainDataTourGroupService.add(req,getCurrentUser(getRequest()));
    }

    /**
     * 编辑旅游组别
     */
    @ApiOperation(value = "编辑旅游组别", notes = "编辑旅游组别")
    @OperationLogAnnotation(operModul = OperationLogModel.SYSTEM, operType = OperationLogType.UPDATE, operTitle = "编辑旅游组别", operDesc = "编辑旅游组别")
    @PostMapping("/update")
    public Result update(@RequestBody @Valid MainDataTourGroupUpdateReq req) {
        return iMainDataTourGroupService.update(req,getCurrentUser(getRequest()));
    }

    /**
     * 编辑旅游组别状态
     */
    @ApiOperation(value = "编辑旅游组别状态", notes = "编辑旅游组别状态")
    @OperationLogAnnotation(operModul = OperationLogModel.SYSTEM, operType = OperationLogType.UPDATE, operTitle = "编辑旅游组别状态", operDesc = "编辑旅游组别状态")
    @PostMapping("/updateStatus")
    public Result updateStatus(@RequestBody @Valid MainDataTourGroupUpdateStatusReq req) {
        TokenUser currentUser = getCurrentUser(getRequest());
        return iMainDataTourGroupService.updateStatus(req,getCurrentUser(getRequest()));
    }

    /**
     * 查看旅游组别
     */
    @ApiOperation(value = "查看旅游组别", notes = "查看旅游组别")
    @OperationLogAnnotation(operModul = OperationLogModel.SYSTEM, operType = OperationLogType.QUERY, operTitle = "查看旅游组别", operDesc = "查看旅游组别")
    @PostMapping("/query")
    public Result<MainDataTourGroupQueryDTO> query(@RequestBody @Valid MainDataTourGroupUpdateStatusReq req) {
        return Result.success(iMainDataTourGroupService.query(req));
    }

    /**
     * 查看旅游组别列表
     */
    @ApiOperation(value = "查看旅游组别列表", notes = "查看旅游组别列表")
    @OperationLogAnnotation(operModul = OperationLogModel.SYSTEM, operType = OperationLogType.QUERY, operTitle = "查看旅游组别列表", operDesc = "查看旅游组别列表")
    @PostMapping("/list")
    public Result<PageResponse<MainDataTourGroupListDTO>> list(@RequestBody @Valid MainDataTourGroupListReq req){
        return Result.success(iMainDataTourGroupService.list(req));
    }

    /**
     * 联动查看旅游组别
     */
    @ApiOperation(value = "联动查看旅游组别", notes = "联动查看旅游组别")
    @OperationLogAnnotation(operModul = OperationLogModel.SYSTEM, operType = OperationLogType.QUERY, operTitle = "查看旅游组别列表", operDesc = "查看旅游组别列表")
    @PostMapping("/list/by/area")
    public Result<MainDataTourGroupDTO> listByArea(@RequestBody @Valid MainDataTourGroupAreaReq req){
        return Result.success(iMainDataTourGroupService.listByArea(req));
    }

    /**
     * 旅游组别联动旅游组别码
     */
    @ApiOperation(value = "旅游组别联动旅游组别码", notes = "旅游组别联动旅游组别码")
    @OperationLogAnnotation(operModul = OperationLogModel.SYSTEM, operType = OperationLogType.QUERY, operTitle = "旅游组别联动旅游组别码", operDesc = "旅游组别联动旅游组别码")
    @PostMapping("/query/group/coed")
    public Result<MainDataTourGroupCodeQueryDTO> queryGroupCode(@RequestBody @Valid MainDataTourGroupUpdateStatusReq req){
        return Result.success(iMainDataTourGroupService.queryGroupCode(req.getId()));
    }

//    /**
//     * 旅行团首页目录三级分类二级菜单
//     * @return
//     */
//    @ApiOperation(value = "旅行团首页目录三级分类二级菜单", notes = "旅行团首页目录三级分类二级菜单")
//    @OperationLogAnnotation(operModul = OperationLogModel.SYSTEM, operType = OperationLogType.QUERY, operTitle = "旅行团首页目录三级分类二级菜单", operDesc = "旅行团首页目录三级分类二级菜单")
//    @PostMapping("/query/home/catalog2")
//    public List<MainDataTourGroupDTO> getCatalogGroup(){
//        return iMainDataTourGroupService.getMainDataTourGroup();
//    }


}
